#include "parafluidatom.h"
#include <QDebug>
using namespace ParaFluid;

Atom::~Atom()
{
	/* does nothing */
}

Atom::Atom()
	: substance()
	, currentDensity(0)
	, currentForce()
	, currentPosition()
	, previousPosition()
	, nextPosition()
{
	/* does nothing */
}

Atom::Atom(const Vector & position, const Substance & s)
	: substance(s)
	, currentDensity(0)
	, currentForce()
	, currentPosition(position)
	, previousPosition(position)
	, nextPosition(position)
{
	/* does nothing */
}

Atom::Atom(const Atom & other)
	: substance(other.substance)
	, currentDensity(other.currentDensity)
	, currentForce(other.currentForce)
	, currentPosition(other.currentPosition)
	, previousPosition(other.previousPosition)
	, nextPosition(other.nextPosition)
{
	/* does nothing */
}

Atom & Atom::operator= (const Atom & rhs)
{
	if(&rhs != this)
	{
		substance = rhs.substance;
		currentDensity = rhs.currentDensity;
		currentForce = rhs.currentForce;
		currentPosition = rhs.currentPosition;
		previousPosition = rhs.previousPosition;
		nextPosition = rhs.nextPosition;
	}
	return *this;
}

bool Atom::operator== (const Atom & rhs) const
{
	bool result = true;
	if(&rhs != this)
	{
		result = (substance == rhs.substance)
		&& (currentDensity == rhs.currentDensity)
		&& (currentForce == rhs.currentForce)
		&& (currentPosition == rhs.currentPosition)
		&& (previousPosition == rhs.previousPosition)
		&& (nextPosition == rhs.nextPosition);
	}
	return result;
}

QDataStream & operator<< (QDataStream & stream, const ParaFluid::Atom & atom)
{
	stream << atom.substance;
	stream << atom.currentDensity;
	stream << atom.currentForce;
	stream << atom.currentPosition;
	stream << atom.previousPosition;
	stream << atom.nextPosition;
	return stream;
}
	
QDataStream & operator>> (QDataStream & stream, ParaFluid::Atom & atom)
{
	stream >> atom.substance;
	stream >> atom.currentDensity;
	stream >> atom.currentForce;
	stream >> atom.currentPosition;
	stream >> atom.previousPosition;
	stream >> atom.nextPosition;
	return stream;
}
